/*
  Toevoegen item:				add()
  Laden lijst van de server:	load()
 */

 
(function($) {

  var objUndo = {
	history: [],
	load: function (url, ul) {
		obj = this;
		$.getJSON(url, function(data){
			obj.history = data;
			obj.showlist(ul);
		});
	},
	showlist: function (ul) {
		obj = this;
		ul.html(obj.mylist());
		ul.find(".undoClick").click(obj.undoClick);
	},
	undoClick: function (a) {
		console.log(a);
	},
	listitem: function (value) {
		return '<li><a relid="'+value['name']+'" href="#" class="undoClick">'+value['name']+'</a></li>';
	},
	mylist: function () {
		html = "";
		$.each(this.history['list'], function(key, value) {
			html += objUndo.listitem(value); 
		});
		return html;
	},
	add: function () {
		this.history
		return true;
	}
  }
 
  $.fn.menuUndo = function(options) {
    var settings = $.extend({}, {open: false}, options);
    return this.each(function() {
		objUndo.load('settings/open/undolist/system', $(this));

		//if (objUndo.load('settings/open/undolist/system')) $(this).ullist(objUndo.menulist());
		//var dts = $(this).children('dt');
		//dts.click(onClick);
		//dts.each(reset);
		//if(settings.open) $(this).children('dt:first-child').next().show();
    });
	
    /*function onClick() {
      $(this).siblings('dt').each(hide);
      $(this).next().slideDown('fast');
      return false;
    }

    function hide() {
      $(this).next().slideUp('fast');
    }

    function reset() {
      $(this).next().hide();
    }*/
  };
})(jQuery);

/*

function objUndoItem (name) {
    this.time = ;
    this.action = action;
    this.db = db;
    this.backupfile = backupfile;
    this.settings = objSettings;
}



*/